Skip to main content

winsafe\mf\com_interfaces/
imftopologynode.rs

1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::macros::*;
6use crate::mf::vts::*;
7use crate::ole::privs::*;
8use crate::prelude::*;
9
10com_interface! { IMFTopologyNode: "83cf873a-f6da-4bc8-823f-bacfd55dc430";
11	/// [`IMFTopologyNode`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nn-mfidl-imftopologynode)
12	/// COM interface.
13	///
14	/// Automatically calls
15	/// [`Release`](https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-release)
16	/// when the object goes out of scope.
17	///
18	/// Usually created with
19	/// [`MFCreateTopologyNode`](crate::MFCreateTopologyNode) function.
20	///
21	/// # Examples
22	///
23	/// ```no_run
24	/// use winsafe::{self as w, prelude::*, co};
25	///
26	/// let topology_node = w::MFCreateTopologyNode(co::MF_TOPOLOGY::OUTPUT_NODE)?;
27	/// # w::HrResult::Ok(())
28	/// ```
29}
30
31impl mf_IMFAttributes for IMFTopologyNode {}
32impl mf_IMFTopologyNode for IMFTopologyNode {}
33
34/// This trait is enabled with the `mf` feature, and provides methods for
35/// [`IMFTopologyNode`](crate::IMFTopologyNode).
36///
37/// Prefer importing this trait through the prelude:
38///
39/// ```no_run
40/// use winsafe::prelude::*;
41/// ```
42pub trait mf_IMFTopologyNode: mf_IMFAttributes {
43	/// [`IMFTopologyNode::CloneFrom`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-clonefrom)
44	/// method.
45	fn CloneFrom(&self, node: &impl mf_IMFTopologyNode) -> HrResult<()> {
46		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).CloneFrom)(self.ptr(), node.ptr()) })
47			.to_hrresult()
48	}
49
50	/// [`IMFTopologyNode::ConnectOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-connectoutput)
51	/// method.
52	fn ConnectOutput(
53		&self,
54		output_index: u32,
55		downstream_node: &impl mf_IMFTopologyNode,
56		input_index_on_downstream_node: u32,
57	) -> HrResult<()> {
58		HrRet(unsafe {
59			(vt::<IMFTopologyNodeVT>(self).ConnectOutput)(
60				self.ptr(),
61				output_index,
62				downstream_node.ptr(),
63				input_index_on_downstream_node,
64			)
65		})
66		.to_hrresult()
67	}
68
69	/// [`IMFTopologyNode::DisconnectOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-disconnectoutput)
70	/// method.
71	#[must_use]
72	fn DisconnectOutput(&self, output_index: u32) -> HrResult<()> {
73		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).DisconnectOutput)(self.ptr(), output_index) })
74			.to_hrresult()
75	}
76
77	/// [`IMFTopologyNode::GetInput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getinput)
78	/// method.
79	///
80	/// Returns the node and the index of the output stream that is connected to
81	/// this node's input stream.
82	#[must_use]
83	fn GetInput(&self, input_index: u32) -> HrResult<(IMFTopologyNode, u32)> {
84		let mut queried = unsafe { IMFTopologyNode::null() };
85		let mut output_index_downstream_node = 0u32;
86		HrRet(unsafe {
87			(vt::<IMFTopologyNodeVT>(self).GetInput)(
88				self.ptr(),
89				input_index,
90				queried.as_mut(),
91				&mut output_index_downstream_node,
92			)
93		})
94		.to_hrresult()
95		.map(|_| (queried, output_index_downstream_node))
96	}
97
98	/// [`IMFTopologyNode::GetInputCount`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getinputcount)
99	/// method.
100	#[must_use]
101	fn GetInputCount(&self) -> HrResult<u32> {
102		let mut c = 0u32;
103		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetInputCount)(self.ptr(), &mut c) })
104			.to_hrresult()
105			.map(|_| c)
106	}
107
108	/// [`IMFTopologyNode::GetNodeType`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getnodetype)
109	/// method.
110	#[must_use]
111	fn GetNodeType(&self) -> HrResult<co::MF_TOPOLOGY> {
112		let mut ty = co::MF_TOPOLOGY::default();
113		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetNodeType)(self.ptr(), ty.as_mut()) })
114			.to_hrresult()
115			.map(|_| ty)
116	}
117
118	/// [`IMFTopologyNode::GetObject`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getobject)
119	/// method.
120	#[must_use]
121	fn GetObject<T>(&self) -> HrResult<T>
122	where
123		T: ole_IUnknown,
124	{
125		let mut queried = unsafe { T::null() };
126		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetObject)(self.ptr(), queried.as_mut()) })
127			.to_hrresult()
128			.map(|_| queried)
129	}
130
131	/// [`IMFTopologyNode::GetOutput`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getoutput)
132	/// method.
133	///
134	/// Returns the node and the index of the input stream that is connected to
135	/// this node's output stream.
136	#[must_use]
137	fn GetOutput(&self, output_index: u32) -> HrResult<(IMFTopologyNode, u32)> {
138		let mut queried = unsafe { IMFTopologyNode::null() };
139		let mut input_index_downstream_node = 0u32;
140		HrRet(unsafe {
141			(vt::<IMFTopologyNodeVT>(self).GetOutput)(
142				self.ptr(),
143				output_index,
144				queried.as_mut(),
145				&mut input_index_downstream_node,
146			)
147		})
148		.to_hrresult()
149		.map(|_| (queried, input_index_downstream_node))
150	}
151
152	/// [`IMFTopologyNode::GetOutputCount`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-getoutputcount)
153	/// method.
154	#[must_use]
155	fn GetOutputCount(&self) -> HrResult<u32> {
156		let mut c = 0u32;
157		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetOutputCount)(self.ptr(), &mut c) })
158			.to_hrresult()
159			.map(|_| c)
160	}
161
162	/// [`IMFTopologyNode::GetTopoNodeID`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-gettoponodeid)
163	/// method.
164	#[must_use]
165	fn GetTopoNodeID(&self) -> HrResult<u64> {
166		let mut id = 0u64;
167		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).GetTopoNodeID)(self.ptr(), &mut id) })
168			.to_hrresult()
169			.map(|_| id)
170	}
171
172	/// [`IMFTopologyNode::SetObject`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-setobject)
173	/// method
174	fn SetObject(&self, object: &impl ole_IUnknown) -> HrResult<()> {
175		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).SetObject)(self.ptr(), object.ptr()) })
176			.to_hrresult()
177	}
178
179	/// [`IMFTopologyNode::SetTopoNodeID`](https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nf-mfidl-imftopologynode-settoponodeid)
180	/// method.
181	fn SetTopoNodeID(&self, topo_id: u64) -> HrResult<()> {
182		HrRet(unsafe { (vt::<IMFTopologyNodeVT>(self).SetTopoNodeID)(self.ptr(), topo_id) })
183			.to_hrresult()
184	}
185}